package com.mqbest.whome;

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;

import com.xs.ctl.ExtensionCmdXml;

public class LomoCtx {
	public static XMPPConnection ConnCtx = null;
	
	public void setXmppCtx (XMPPConnection ctx){
		ConnCtx = ctx;
	}
	
	public XMPPConnection getXmppCtx(){
		return ConnCtx;
	}
	
	public void SendCmd(String to, String cmd, String DeiveId){
		Message CmdMsg = new Message(to, Message.Type.chat);
		ExtensionCmdXml myExtension = new ExtensionCmdXml();
		
		myExtension.setCmd(cmd);
		myExtension.setDeviceID(DeiveId);
		CmdMsg.setTo(to);
		CmdMsg.addExtension(myExtension);
		
		ConnCtx.sendPacket(CmdMsg);
	}
	
	public void releaseXmppCtx(){
		if(null != ConnCtx){
			ConnCtx.disconnect();
			ConnCtx = null;
		}
	}
}